package top.baselitch.liteorm;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.Map;
public class DaoExecutor<D> {
    private DaoMethod daoMethod;
    private LiteDBHelper dbHelper;
    public DaoExecutor(LiteDBHelper dbHelper,DaoMethod daoMethod){
        this.daoMethod = daoMethod;
        this.dbHelper = dbHelper;
    }
    public D exec(Class<D> dClass){
        if(daoMethod.getDaoAction() == DaoMethod.ACTION_INSERT){
            SQLiteDatabase sqLiteDatabase = dbHelper.getWritableDatabase();
            sqLiteDatabase.insert(daoMethod.getTableName(),null,daoMethod.getInserDatas());
        }else if(daoMethod.getDaoAction() == DaoMethod.ACTION_DELETE){
            SQLiteDatabase sqLiteDatabase = dbHelper.getWritableDatabase();
            sqLiteDatabase.delete(daoMethod.getTableName(),null,null);
        }else if(daoMethod.getDaoAction() == DaoMethod.ACTION_UPDATE){
            SQLiteDatabase sqLiteDatabase = dbHelper.getWritableDatabase();
            sqLiteDatabase.update(daoMethod.getTableName(),null,null,null);
        }else if(daoMethod.getDaoAction() == DaoMethod.ACTION_QUERY){
            SQLiteDatabase sqLiteDatabase = dbHelper.getReadableDatabase();
            Cursor cursor = sqLiteDatabase.query(daoMethod.getTableName(),daoMethod.getQueryColumnts(),daoMethod.getQuerySelection(),daoMethod.getSelectionArgs(),null,null,null,null);
            while(cursor.moveToNext()){

            }
        }
        return null;
    }
}
